package cn.gong.movie.data;

import z.database.callback.DBCallBack;
import z.database.callback.DBDeal;
import android.widget.AdapterView.OnItemClickListener;
import cn.gong.movie.bean.Movie;
import cn.gong.movie.db.DbMovie;
import cn.gong.movie.enums.DbTaskType;

public class DataMovie extends DataBase {
	public static void setMovie(final Movie movie, DBCallBack callBack) {
		deal(DbTaskType.dbTsSetMovie, callBack, new DBDeal() {

			@Override
			public Object deal(Object obj) {
				// new DbMovie().setMovies(movie);
				return new DbMovie().setMovie(movie);
			}
		});
	}

	public static void getMovies(final long lastId, final int status, DBCallBack callBack) {
		deal(DbTaskType.dbTsGetMovies, callBack, new DBDeal() {

			@Override
			public Object deal(Object obj) {
				return new DbMovie().getMovies(lastId, status);
			}
		});
	}

	public static void getMoreMovies(final long lastId, final int status, DBCallBack callBack) {
		deal(DbTaskType.dbTsGetMoreMovies, callBack, new DBDeal() {

			@Override
			public Object deal(Object obj) {
				return new DbMovie().getMovies(lastId, status);
			}
		});
	}

	public static void changeStatus(final long id, final int status, DBCallBack callBack) {
		deal(DbTaskType.dbTsChangeMovieStatus, callBack, new DBDeal() {

			@Override
			public Object deal(Object obj) {
				new DbMovie().changeStatus(id, status);
				return null;
			}
		});
	}

	public static void deleteMovie(final long id,DBCallBack callBack) {
		deal(DbTaskType.dbTsDeleteMovie, callBack, new DBDeal() {

			@Override
			public Object deal(Object obj) {
				new DbMovie().deleteMovie(id);
				return null;
			}
		});
	}

	public static void updateMovie(final Movie movie, DBCallBack callBack) {
		deal(DbTaskType.dbTsUpdateMovie, callBack, new DBDeal() {

			@Override
			public Object deal(Object obj) {
				// new DbMovie().setMovies(movie);
				return new DbMovie().updateMovie(movie);
			}
		});
	}
}
